package _2_factory_method

type Operator interface {
	setC(int)
	setD(int)
	result() int
}

type OperatorFactory interface {
	Create() Operator
}

type OperatorBase struct {
	a,b int
}

func (self *OperatorBase)setC(num int){
	self.a = num
}

func (self *OperatorBase)setD(num int) {
	self.b = num
}

type PlusOperatorFactory struct {}

func (self *PlusOperatorFactory)Create() Operator  {
	return &PlusOperator{
		&OperatorBase{},
	}
}

type PlusOperator struct {
	*OperatorBase
}

func (self *PlusOperator) result()int{
	return self.a + self.b;
}
type MinusOperatorFactory struct {}

func (self *MinusOperatorFactory) Create() Operator{
	return &MinusOperator{
		&OperatorBase{},
	}
}

type MinusOperator struct {
	*OperatorBase
}

func (self *MinusOperator)result() int {
	return  self.a -self.b
}

